﻿using System;

namespace Mono.Rift.Core.Graphics
{
	public class Color
	{
		public byte R { get; set; }
		public byte G { get; set; }
		public byte B { get; set; }
		public byte A { get; set; }

		public Color (byte r, byte g, byte b, byte a = 0xff)
		{
			R = r;
			G = g;
			B = b;
			A = a;
		}

		public Color(uint c)
		{
			R = (byte)((c >> 16) & 255);
			G = (byte)((c >> 8) & 255);
			B = (byte)(c & 255);
			A = (byte)((c >> 24) & 255);
		}

		public static Color create(byte r, byte g, byte b, byte a)
		{
			return new Color (r, g, b, a);
		}

		public void getRGBA(out float r, out float g, out float b, out float a)
		{
			r = R / 255.0f;
			g = G / 255.0f;
			b = B / 255.0f;
			a = A / 255.0f;
		}

		public override bool Equals (object obj)
		{
			var c = obj as Color;
			if (c == null) return false;
			return base.Equals(obj) && R == c.R && G == c.G && B == c.B && A == c.A;
		}

		public override int GetHashCode ()
		{
			return base.GetHashCode ();
		}
	}
}

